import { createRouter, createWebHistory } from 'vue-router';

// 页面组件
import Home from './views/Home.vue'
import Employee from './views/Employee.vue'
import Attendance from './views/Attendance.vue'
import Approval from './views/Approval.vue'
import Punch from './views/Punch.vue'


// 每个路由都需要映射到一个组件。
const routes = [
  { title: '首页', path: '/', component: Home},
  { title: '员工管理', path: '/Employee', component: Employee },
  { title: '考勤管理', path: '/Attendance', component: Attendance },
  { title: '审批管理', path: '/Approval', component: Approval },
  { title: '打卡管理', path: '/Punch', component: Punch },
]

//map() 方法调用，它遍历 routes 数组的每个元素，并将每个元素映射为一个新的对象。
export const menuItems = routes.map(ele => ({path: ele.path, title: ele.title}))

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
